$(function () {

	$(".head-nav li").hover(function () {
		$(this).find(".iconfont").addClass("on-i");
	}, function () {
		$(this).find(".iconfont").removeClass("on-i");
	})


	$(".m_l_con .dl-btn").hover(function () {
		$(this).siblings(".download-ico").show(0, function () {
			$(this).hover(function () {
				$(this).show();
			}, function () {
				$(this).hide();
			})

		});
	}, function () {
		$(this).siblings(".download-ico").hide();
	})



	// $(window).scroll(function () {

	//    var scrollT = $(this).scrollTop();

	//    if (scrollT>100) {
	//     $(".head-2-2").addClass("head-2-con");
	//    }else{
	//    	$(".head-2-2").removeClass("head-2-con");
	//    };

	// });


	$(".m-download").hover(function () {
		$(this).siblings(".download-ico").show(0, function () {
			$(this).hover(function () {
				$(this).show();
			}, function () {
				$(this).hide();
			})

		});
	}, function () {
		$(this).siblings(".download-ico").hide();
	})

	$(".data-info-public .signa").keyup(function () {
		var le = $(".data-info-public .signa").val().length;
		console.log(le)
		$("#numTip em").html(250 - le);
	})


	var mydate = new Date();
	// var str = "" + mydate.getFullYear() + "年";
	var str = (mydate.getMonth() + 1) + "月";
	str += mydate.getDate() + "日";


	$(".dq-time").html(str);



	$(".yh-en").click(function () {
		layer.open({
			title: '',
			area: ['300px', '320px'],
			type: 1,

			shadeClose: true,//遮罩关闭
			anim: 0,
			content: '<div class="dl-box yzmdl">' +
				// '<div class="bq-kuang"></div>'+
				'<form action="/index.php?g=user&m=Register&a=yzmlogin" method="post">' +
				'<h4>手机登录</h4>' +
				'<div class="dl-box-yzm">' +
				'<div class="dl-box-tb">' +
				'<i></i>' +
				'</div>' +
				'<input type="text" name="mobile" id="mobile"  placeholder="手机号">' +
				'</div>' +
				'<div class="dl-box-code" style="border: 0">' +
				'<input type="text" name="code"  placeholder="验证码" style="width: 120px;line-height: 20px;border: 1px solid #C9C9C9;">' +
				'<input type="button" id="yzm" class="dl-box-mfyzm" value="点击发送">' +
				'</div>' +
				'<div class="tishi"></div>' +
				'<div class="wjmm">' +
				'<a href="/index.php?g=user&m=login&a=edlog">忘记密码？</a>' +
				'</div>' +
				'<input type="submit" value="登录" class="zhdl" id="dl"></input>' +
				'<div class="dlfs">' +
				'<span id="change_login_username">密码登录</span>' +
				'</div>' +
				'</form>' +

				'</div>' +
				'<div class="dl-box mmdl" style="display: none;">' +
				// '<div class="bq-kuang"></div>'+
				'<form action="/index.php?g=user&m=Register&a=login" method="post">' +
				'<h4>账号登录</h4>' +
				'<div class="dl-box-yh">' +
				'<div class="dl-box-tb">' +
				'<i></i>' +
				'</div>' +
				'<input type="text" name="username"  placeholder="账号"></input>' +
				'</div>' +
				'<div class="dl-box-mm">' +
				'<div class="dl-box-tb">' +
				'<i></i>' +
				'</div>' +
				'<input type="password" name="password"  placeholder="密码"  maxlength="22"></input>' +
				'</div>' +
				'<div class="tishi"></div>' +
				'<div class="wjmm">' +
				'<a href="/index.php?g=user&m=login&a=edlog">忘记密码？</a>' +
				'</div>' +
				'<input type="submit" value="登录" class="zhdl" id="dl"></input>' +
				'<div class="dlfs">' +
				'<span id="change_login_yzm">手机登录</span>' +
				'</div>' +
				'</form>' +
				'</div>' +
				'<input type="text" id="login_type" name="login_type" value="mobile" style="display: none">' +
				'<div class="dl-box ewmdl" style="display: none;">' +
				'<div class="bq-ewm"></div>' +

				'<h4>扫码登录</h4>' +
				'<div class="ewm-k">' +
				'<img src="">' +
				'</div>' +
				'<p>打开<span>游戏盒子</span>，扫一扫二维码登录</p>' +



				'</div>',
			success: function () {

				$(".dl-box .zhdl").click(function () {
					$(".tishi").html('');
					var login_type = $("#login_type").val();

					if (login_type == 'mobile') {
						var mobile = $(".dl-box-yzm input").val();
						var code = $(".dl-box-code input").val();

						if (mobile == "") {
							$(".tishi").html('<i class="ico-jg">' + 'x' + '</i>' + '手机号不能为空！')
							return false;
						} else {
							$(".tishi").html('');
							if (code == "") {
								$(".tishi").html('<i class="ico-jg">' + 'x' + '</i>' + '验证码不能为空！')
								return false;
							}
						}
					} else {
						var zhao = $(".dl-box-yh input").val();
						var mima = $(".dl-box-mm input").val();
						if (zhao == "") {
							$(".tishi").html('<i class="ico-jg">' + 'x' + '</i>' + '账号不能为空！')
							return false;
						} else {
							$(".tishi").html('');
							if (mima == "") {
								$(".tishi").html('<i class="ico-jg">' + 'x' + '</i>' + '密码不能为空！')
								return false;
							}
						}
					}
				})

			}
		});


	})
	var wait = 60;
	function time(o) {
		if (wait == 0) {
			o.removeAttribute("disabled");
			o.value = "重新获取 ";
			wait = 70;
		} else {
			o.setAttribute("disabled", true);
			o.value = wait + "秒再获取";
			wait--;
			setTimeout(function () {
				time(o)
			},
				1000)
		}
	}
	$(document).on('click', '#yzm', function () {
		var that = this;

		/* 判断是否填写手机号 */
		var val = $("#mobile").val();
		if (!val) {
			layer.msg("请填写手机号")
			$("#telnum").focus();
			return;
		}

		$.ajax({
			url: '/User/Register/yzm_login.html',
			type: "POST",
			dataType: "json",
			data: { val: val, type: '6' },
			success: function (data) {
				console.log(data)
				if (data.a == 'success') {
					layer.msg("发送成功")
				}

				time(that);
			}
		});
	})
	$(document).on('click', '#change_login_username', function () {
		$('.yzmdl').hide()
		$('.mmdl').show()
		$("#login_type").val('username')
	})
	$(document).on('click', '#change_login_yzm', function () {
		$('.yzmdl').show()
		$('.mmdl').hide()
		$("#login_type").val('mobile')
	})
	/* */
	//解锁折扣 关闭
	$(document).on('click', '.popup-close', function () {
		layer.closeAll();
	})
	//解锁折扣 打开
	$(document).on('click', '.sqjs-btn', function (e) {
		e.stopPropagation();
		e.preventDefault();
		layer.open({
			type: 1,
			title: false, // 不显示标题栏
			closeBtn: 0,
			shadeClose: true, // 点击遮罩关闭层
			content: `<div class="popup-jszk">
					<img class="popup-jszk-close" src="/themes/simplebootx/Public/sub/images/cancel_order.png" alt="">
					<div class="jszk-head">解锁折扣</div>
					<div class="jszk-img">
						<img src="/themes/simplebootx/Public/sub/images/xjszk.png" alt="">
					</div>
					<div class="jszk-p">该内容详细折扣，请联系客服</div>
					<a class="jszk-u" href="/service">联系客服</a>
				</div>`
		});
	})
	//预约 关闭
	$(document).on('click', '.popup-jszk-close', function () {
		layer.closeAll();
	})
	//预约 打开
	$(document).on('click', '.yy-btn', function (e) {
		e.stopPropagation();
		e.preventDefault();
		layer.open({
			type: 1,
			title: false, // 不显示标题栏
			closeBtn: 0,
			shadeClose: true, // 点击遮罩关闭层
			content: ` <div class="popup-ty">
				<img class="popup-close" src="/themes/simplebootx/Public/sub/images/cancel_order.png" alt="">
				<div class="pty-head">
					<span>请打开</span><em>SSS手游客户端</em><span>体验</span>
				</div>
				<div class="pty-ewm">
					<img src="/themes/simplebootx/Public/sub/images/renwu/ewm.png" alt="">
				</div>
				<div class="pty-p">
					<span>请打开</span><em>SSS手游客户端</em><span>体验</span>
				</div>
				<div class="pty-u">
					<span id="shortUrl">https://www.sssgo.com/game/index/box.html</span>
					<em data-clipboard-text="https://www.sssgo.com/game/index/box.html" id="copyUrl">复制</em>
				</div>
			</div>`
		});
	})
	//弹窗 复制
	function initCopy() {
		let clipboard = new ClipboardJS('#copyUrl');
		clipboard.on('success', function (e) {
			layer.msg('复制成功')
		});
		clipboard.on('error', function (e) {
			layer.msg('复制失败')
		});
	}
	try {
		initCopy()
	} catch (error) { }
	/*返回顶部*/
	$('#goTop').on('click', function (e) {
		e.preventDefault();
		$('html, body').animate({ scrollTop: 0 }, '300');
	});

})



//拼接参数
function paramsSplicing(url, params) {
	for (const key in params) {
		url += url.includes('?') ? '&' + key + '=' + params[key] : '?' + key + '=' + params[key];
	}
	return url;
}
//获取参数
function getString(name, str) {
	let arr = str.substr(str.indexOf('?') + 1).split('&');
	for (var i = 0; i < arr.length; i++) {
		var index = arr[i].indexOf('=');
		if (arr[i].substring(0, index) == name) {
			return arr[i].substr(index + 1)
		}
	}
}